; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals
; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -passes=inline < %s | FileCheck %s
; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -passes='cgscc(inline)' < %s | FileCheck %s

define i32 @func_default() #0 {
; CHECK-LABEL: define {{[^@]+}}@func_default
; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
; CHECK-NEXT:    ret i32 0
;
  ret i32 0
}

define i32 @func_unsafe_fp_atomic_enabled() #1 {
; CHECK-LABEL: define {{[^@]+}}@func_unsafe_fp_atomic_enabled
; CHECK-SAME: () #[[ATTR1:[0-9]+]] {
; CHECK-NEXT:    ret i32 0
;
  ret i32 0
}

define i32 @func_unsafe_fp_atomic_disabled() #2 {
; CHECK-LABEL: define {{[^@]+}}@func_unsafe_fp_atomic_disabled
; CHECK-SAME: () #[[ATTR2:[0-9]+]] {
; CHECK-NEXT:    ret i32 0
;
  ret i32 0
}

define i32 @default_call_default() #0 {
; CHECK-LABEL: define {{[^@]+}}@default_call_default
; CHECK-SAME: () #[[ATTR0]] {
; CHECK-NEXT:    ret i32 0
;
  %call = call i32 @func_default()
  ret i32 %call
}

define i32 @unsafe_fp_atomic_enabled_call_default() #1 {
; CHECK-LABEL: define {{[^@]+}}@unsafe_fp_atomic_enabled_call_default
; CHECK-SAME: () #[[ATTR1]] {
; CHECK-NEXT:    ret i32 0
;
  %call = call i32 @func_default()
  ret i32 %call
}

define i32 @unsafe_fp_atomic_enabled_call_unsafe_fp_atomic_enabled() #1 {
; CHECK-LABEL: define {{[^@]+}}@unsafe_fp_atomic_enabled_call_unsafe_fp_atomic_enabled
; CHECK-SAME: () #[[ATTR1]] {
; CHECK-NEXT:    ret i32 0
;
  %call = call i32 @func_unsafe_fp_atomic_enabled()
  ret i32 %call
}

define i32 @unsafe_fp_atomic_enabled_call_unsafe_fp_atomic_disabled() #1 {
; CHECK-LABEL: define {{[^@]+}}@unsafe_fp_atomic_enabled_call_unsafe_fp_atomic_disabled
; CHECK-SAME: () #[[ATTR1]] {
; CHECK-NEXT:    ret i32 0
;
  %call = call i32 @func_unsafe_fp_atomic_disabled()
  ret i32 %call
}

define i32 @unsafe_fp_atomic_disabled_call_default() #2 {
; CHECK-LABEL: define {{[^@]+}}@unsafe_fp_atomic_disabled_call_default
; CHECK-SAME: () #[[ATTR2]] {
; CHECK-NEXT:    ret i32 0
;
  %call = call i32 @func_default()
  ret i32 %call
}

define i32 @unsafe_fp_atomic_disabled_call_unsafe_fp_atomic_enabled() #2 {
; CHECK-LABEL: define {{[^@]+}}@unsafe_fp_atomic_disabled_call_unsafe_fp_atomic_enabled
; CHECK-SAME: () #[[ATTR2]] {
; CHECK-NEXT:    ret i32 0
;
  %call = call i32 @func_unsafe_fp_atomic_enabled()
  ret i32 %call
}

define i32 @unsafe_fp_atomic_disabled_call_unsafe_fp_atomic_disabled() #2 {
; CHECK-LABEL: define {{[^@]+}}@unsafe_fp_atomic_disabled_call_unsafe_fp_atomic_disabled
; CHECK-SAME: () #[[ATTR2]] {
; CHECK-NEXT:    ret i32 0
;
  %call = call i32 @func_unsafe_fp_atomic_disabled()
  ret i32 %call
}

attributes #0 = { nounwind }
attributes #1 = { nounwind "amdgpu-unsafe-fp-atomics"="true" }
attributes #2 = { nounwind "amdgpu-unsafe-fp-atomics"="false" }
;.
; CHECK: attributes #[[ATTR0]] = { nounwind }
; CHECK: attributes #[[ATTR1]] = { nounwind "amdgpu-unsafe-fp-atomics"="true" }
; CHECK: attributes #[[ATTR2]] = { nounwind "amdgpu-unsafe-fp-atomics"="false" }
;.
